let name: any = 'Henry'
let name2: unknown = 'Henry'

let a: string = name // 正常
// let b: string = name2 // 编译报错: 不能将类型“unknown”分配给类型“string”

let c: string = name2 as string

console.log('===')

let age: string = '18'

// let age2: number = age as number // 类型 "string" 到类型 "number" 的转换可能是错误的，因为两种类型不能充分重叠。如果这是有意的，请先将表达式转换为 "unknown"
let age2: number = age as unknown as number

console.log('===')

const person: unknown = {
  id: 101,
  name: 'Henry',
  sayHello: () => console.log('Hello')
}

// person.id // 编译报错: 属性“id”在类型“unknown”上不存在
// person.sayHello() // 编译报错: 属性“sayHello”在类型“unknown”上不存在

const person2: any = {
  id: 101,
  name: 'Henry',
  sayHello: () => console.log('Hello')
}
person2.id // 正常
person2.sayHello() // 正常

export {}
